package example.dawangba.com.z09315222_finalandroidhomework;

import android.app.Activity;
import android.os.Bundle;
import android.widget.VideoView;

import java.io.File;

public class VideoPlayTest extends Activity {

    private VideoView videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_play_test);
        videoView = (VideoView) findViewById(R.id.video_view);
        initVideoPath();
    }

    private void initVideoPath() {
        //获取刚才的Activity传输过来的播放路径
        String filePath = getIntent().getStringExtra("path");
        File file = new File(filePath);
        videoView.setVideoPath(file.getPath()); // 指定视频文件的路径
        videoView.start();//播放视频
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (videoView != null) {
            videoView.suspend();
        }
    }
}
